﻿using System.Collections.Generic;
using System.ComponentModel.Composition.Hosting;
using System.ComponentModel.Composition.Primitives;

using System.Reflection;

namespace Mefisto4.Core.MEF
{
    public class CatalogBuilder
    {
        private readonly IList<ComposablePartCatalog> _catalogs = new List<ComposablePartCatalog>();

        public CatalogBuilder ForAssembly(Assembly assembly)
        {
            _catalogs.Add(new AssemblyCatalog(assembly));
            return this;
        }

        public CatalogBuilder ForAssembliesInDirectory(string directory)
        {
            _catalogs.Add(new SafeDirectoryCatalog(directory));
            return this;
        }

        public CatalogBuilder ForMvcAssembly(Assembly assembly)
        {
            _catalogs.Add(new MVCCatalog(assembly));
            return this;
        }

        public CatalogBuilder ForMvcAssembliesInDirectory(string directory)
        {
            _catalogs.Add(new MVCCatalog(directory));
            return this;
        }

        public ComposablePartCatalog Build()
        {
            return new AggregateCatalog(_catalogs);
        }
 
    }
}